package com.seed.core.pojo.seed;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.seed.core.enumeration.ActionType;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class Action1 {
    private String name; // 功能名称，自定义
    private ActionType type; // 功能类型
    private List<RequestMethod> methods;
    private String declare; // 设置值的列名, 当类型为set时，这里表示要设置的申明
    private String declareValue; // 要设置的申明的值
//    private Map<String, Column> columns; // 这里定义的列可以覆盖通用列

    private String seedName; // 独立行为依赖的seed名称

    private List<String> declares; // 功能所需要的数据列
    private List<String> searches; // 如果是功能是page或list，这里申明对应的搜索拦，形如：name_like,age_eq等
    private List<String> orders; // 排序
    private Map<String, Stat> stats;

    private Boolean checkLogin; // 是否需要检查登录
    private Boolean checkAction; // 是否需要检查功能权限
//    private Boolean checkData; // 是否需要检查数据权限
//    private Boolean checkField; // 是否需要检查字段权限
//    private Boolean useKeyword; // 是否需要关键字查询

//    public static Action of(String name, ActionType type) {
//        Action action = new Action();
//        action.setName(name);
//        action.setType(type);
////        action.setMethod(switch (type) {
////            case page, detail, get, stat, exportExcel -> RequestMethod.GET;
////            case save, saves, importExcel -> RequestMethod.POST;
////            case update, updates, set, sets -> RequestMethod.PUT;
////            case remove, removes -> RequestMethod.DELETE;
////        });
//
//        return action;
//    }
//
//    public Action copy() {
//        Action ret = new Action();
//        ret.setName(name);
//        ret.setType(type);
//        ret.setMethods(methods);
//
//        ret.setDeclare(declare);
//        ret.setDeclareValue(declareValue);
////        if(this.columns != null) {
////            Map<String, Column> columns = new HashMap<>();
////            for(Map.Entry<String, Column> entry: this.columns.entrySet()) {
////                columns.put(entry.getKey(), entry.getValue().clone());
////            }
////            ret.setColumns(columns);
////        }
//        ret.setSeedName(seedName);
//
//        if(declares != null) ret.setDeclares(new ArrayList<>(declares));
//        if(searches != null) ret.setSearches(new ArrayList<>(searches));
//        if(orders != null) ret.setOrders(new ArrayList<>(orders));
//        if(stats != null) ret.setStats(stats);
//
//        ret.setCheckLogin(checkLogin);
//        ret.setCheckAction(checkAction);
////        ret.setCheckData(checkData);
////        ret.setCheckField(checkField);
////        ret.setUseKeyword(useKeyword);
//
//        return ret;
//    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ActionType getType() {
        return type;
    }

    public void setType(ActionType type) {
        this.type = type;
    }

    public List<RequestMethod> getMethods() {
        return methods;
    }

    public void setMethods(List<RequestMethod> methods) {
        this.methods = methods;
    }
//    public ActionPosition[] getPosition() {
//        return position;
//    }
//
//    public void setPosition(ActionPosition[] position) {
//        this.position = position;
//    }
//
//    public String getIcon() {
//        return icon;
//    }
//
//    public void setIcon(String icon) {
//        this.icon = icon;
//    }
//
//    public String getColor() {
//        return color;
//    }
//
//    public void setColor(String color) {
//        this.color = color;
//    }
//
//    public Integer getSize() {
//        return size;
//    }
//
//    public void setSize(Integer size) {
//        this.size = size;
//    }
//
//    public String getHoverColor() {
//        return hoverColor;
//    }
//
//    public void setHoverColor(String hoverColor) {
//        this.hoverColor = hoverColor;
//    }
//
//    public String getComponent() {
//        return component;
//    }
//
//    public void setComponent(String component) {
//        this.component = component;
//    }
//
//    public Map<String, Object> getComponentProps() {
//        return componentProps;
//    }
//
//    public void setComponentProps(Map<String, Object> componentProps) {
//        this.componentProps = componentProps;
//    }

//    public String getLabel() {
//        return label;
//    }
//
//    public void setLabel(String label) {
//        this.label = label;
//    }
//
//    public String getComment() {
//        return comment;
//    }
//
//    public void setComment(String comment) {
//        this.comment = comment;
//    }

    public String getDeclare() {
        return declare;
    }

    public void setDeclare(String declare) {
        this.declare = declare;
    }

    public String getDeclareValue() {
        return declareValue;
    }

    public void setDeclareValue(String declareValue) {
        this.declareValue = declareValue;
    }

//    public Map<String, Column> getColumns() {
//        return columns;
//    }
//
//    public void setColumns(Map<String, Column> columns) {
//        this.columns = columns;
//    }

    public String getSeedName() {
        return seedName;
    }

    public void setSeedName(String seedName) {
        this.seedName = seedName;
    }

    public List<String> getDeclares() {
        return declares;
    }

    public void setDeclares(List<String> declares) {
        this.declares = declares;
    }

    public List<String> getSearches() {
        return searches;
    }

    public void setSearches(List<String> searches) {
        this.searches = searches;
    }

    public List<String> getOrders() {
        return orders;
    }

    public void setOrders(List<String> orders) {
        this.orders = orders;
    }

    public Map<String, Stat> getStats() {
        return stats;
    }

    public void setStats(Map<String, Stat> stats) {
        this.stats = stats;
    }

    public Boolean getCheckLogin() {
        return checkLogin;
    }

    public void setCheckLogin(Boolean checkLogin) {
        this.checkLogin = checkLogin;
    }

    public Boolean getCheckAction() {
        return checkAction;
    }

    public void setCheckAction(Boolean checkAction) {
        this.checkAction = checkAction;
    }

//    public Boolean getCheckData() {
//        return checkData;
//    }
//
//    public void setCheckData(Boolean checkData) {
//        this.checkData = checkData;
//    }
//
//    public Boolean getCheckField() {
//        return checkField;
//    }
//
//    public void setCheckField(Boolean checkField) {
//        this.checkField = checkField;
//    }
//
//    public Boolean getUseKeyword() {
//        return useKeyword;
//    }
//
//    public void setUseKeyword(Boolean useKeyword) {
//        this.useKeyword = useKeyword;
//    }
}
